package semantic.analyzer;

import metamodel.PrimitiveTypeEnum;
import semantic.SemanticException;
import semantic.model.ExpressionNode;
import semantic.model.UndefinedExpressionNode;

public class RelationalExpressionAnalyzer {

	public static void checkType(ExpressionNode... nodes) throws Exception {
		for (ExpressionNode node : nodes) {
			if (node != null && node.getType().equalsIgnoreCase(PrimitiveTypeEnum.UNDEFINED.name())) {
				UndefinedExpressionNode uNode = (UndefinedExpressionNode) node;
				uNode.setTypeItShouldBe(PrimitiveTypeEnum.BOOLEAN.name());
			} else if ((node != null) && !node.getType().equalsIgnoreCase(PrimitiveTypeEnum.BOOLEAN.name())) {
				throw new SemanticException("Era esperado tipo booleano!");
			}
		}
	}

}
